<template>
	<view class="mainpadding">
		<view class="mainpadding4 flexcolumn margin_top7">
			<view class="xiaohei ershiba">实付金额</view>
			<view class="xiaohei fonweight margin_top5" style="font-size: 50rpx;">￥{{price}}</view>
		</view>
		<view class="margin_top7 flexbetween ffffff radius mainpadding">
			<view class="flexleft">
				<image src="../static/images/system/jb.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="xiaohei ershiba margin_left2">金币</view>
			</view>
			<u-icon name="checkmark-circle-fill" color="#FF8000" size="20"></u-icon>
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="submit()" v-if="order_id==''">立即支付</view>
			<view class="bigbtn" @click="pay(order_id)" v-if="order_id!=''">立即支付</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				price:"",
				listid:"",
				order_id:""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.price = options.price
			if(options.order_id){
				this.order_id = options.order_id
			}
		},
		methods: {
			submit(){
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/ordercl/addOrder', 'POST', {
					dmkj_id: this.listid
				}, false, false, true).then(res => {
					if(res.code==1){
						this.pay(res.data.order_id)
					}else{
						httpRequest.toast(res.msg)
						uni.hideLoading()
					}
				})
			},
			pay(order_id){
				httpRequest.request('/api/ordercl/payment', 'POST', {
					order_id
				}, false, false, true).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
		}
	}
</script>

<style>

</style>
